/**
 * Project Name:swt-hello <br/>
 * File Name:App.java <br/>
 * Package Name:com.ftu.z <br/>
 */
package com.ftu.swt.basic1;

import org.eclipse.swt.SWT;
import org.eclipse.swt.events.MouseAdapter;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;


/**
 * <p>  </p>
 * @version 1.0 2018年11月22日 mq 修改内容:初版
 */
public class ManualDispose {
    public static void main(String[] args) {
        final Display display = Display.getDefault();
        Shell shell1 = new Shell(display);
        
        shell1.setText("shell1");
        shell1.setSize(400, 400);
        
        final Label label = new Label(shell1, SWT.NONE);
        label.setBounds(10, 10, 40, 20);
        label.setText("Abcd");
        label.setFont(new Font(display, "consolas", 12, SWT.ITALIC));
        label.setBackground(display.getSystemColor(SWT.COLOR_BLACK));
        label.setForeground(new Color(display, 255, 255, 255));
        
        shell1.layout();
        shell1.addMouseListener(new MouseAdapter() {
            @Override
            public void mouseDown(MouseEvent e) {
                if(e.button == 1) {
                    label.dispose();
                } else {
                    label.setText("B");
                }
            }
        });
        
        
        shell1.open();
        while(!shell1.isDisposed()) {
            if(!display.readAndDispatch()) {
                display.sleep();
            }
        }
        display.dispose();
        
    }

}
